<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <link href="kindeditor-4.1.10/themes/default/default.css" type="text/css" rel="stylesheet">
    <script src="layui/layui.js"></script>
    <script type="text/javascript" src="/js/common.js"></script>   
     <script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>   
   <script type="text/javascript" charset="utf-8" src="kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script type="text/javascript" charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
</head>
<body>
<form class="layui-form" id="article">
    
    <div class="layui-inline">
        <label class="layui-form-label">文章标题:</label>
        <div class="layui-input-inline">
        <input type="hidden" name="arid" value="${article.arid}" id="arid">
            <input type="text" name="artitle" placeholder="请输入修改文章标题" lay-verify="required" autocomplete="off"
                   class="layui-input" value="${article.artitle}" id="artitle" >
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">文章内容:</label>
        <div class="layui-input-inline">
          
                    <textarea style="width:800px;height:300px;" name="arcontent" id="arcontent" >${article.arcontent}</textarea>
        </div>
    </div>

    <div class="layui-inline">
        <label class="layui-form-label">文章简介:</label>
        <div class="layui-input-inline">
             <textarea placeholder="请输入内容" class="layui-textarea" name="simpledes" id="simpledes" >${article.simpledes}</textarea>
        </div>
    </div>

     <div class="layui-form-item">
    <label class="layui-form-label">审核</label>
    <div class="layui-input-block">
    <c:if test="${article.isView==false}">
        <input type="radio" name="isView" value="1" title="已审核" check="true" >
   <input type="radio" name="isView" value="0" title="待审核"   >
      </c:if>
      <c:if test="${article.isView==true}">
         <input type="radio" name="isView" value="0" title="待审核" check="true"  >
         <input type="radio" name="isView" value="1" title="已审核"  >
         
      </c:if>   
         
      
  
    </div>
  </div>

     <div class="layui-form-item">
    <label class="layui-form-label">置顶</label>
    <div class="layui-input-block">
    <c:if test="${article.isTop==0}">
        <input type="radio" name="isTop" value="1" title="置顶" check="true" >
   <input type="radio" name="isTop" value="0" title="不置顶"  >
      </c:if>
      <c:if test="${article.isTop==1}">
         <input type="radio" name="isTop" value="0" title="不置顶" check="true" >
         <input type="radio" name="isTop" value="1" title="置顶" >
         
      </c:if>   
         
      
  
    </div>
  </div>
  
      <div class="layui-form-item">
    <label class="layui-form-label">作者</label>
    <div class="layui-input-inline">
    	<input type="hidden" name="uid" value="${users.uid}" id="uid">
      <input type="text" name="username" value="${article.username}" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <br><br>
  <div class="layui-form-item">
    <label class="layui-form-label">点击率</label>
    <div class="layui-input-inline">
      <input type="text" name="clicks"  id="clicks" value="${article.clicks}" lay-verify="required" placeholder="请输入"  autocomplete="off" class="layui-input">
    </div>
  </div>

    <div class="layui-form-item">
        <label class="layui-form-label">文章分类:</label>
        <div class="layui-input-block">
            <select name="artypeid" id="artypeid">
            <c:forEach items="${articleType}" var="t">
                <option value="${t.id}">${t.typname}</option>             
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">文章图片:</label>
                                <div class="layui-input-inline">
                                    <input type="file" name="pic" id="test3" placeholder="图片地址" lay-verify="readonly"
                                           autocomplete="off" class="layui-input">
                                           <input type="text" name="img" id="img" placeholder="图片地址" lay-verify="readonly"
                                           autocomplete="off" class="layui-input" >
                                           <img alt="" src="${article.img}" style="width:100px;height:100px;">
                                </div>
                        
                            </div>
                            </div>
                      
                             <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="saveUpdate">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
</form>
<script>
var arcontent ;
	$(function(){
		//实例化编辑器
		 arcontent = BLOG.createEditor("#article[name=arcontent]");
	});
   layui.use('form', function () {
        var form = layui.form;
        //监听提交
 
            //监听提交
        form.on('submit(saveUpdate)', function (res) {
       arcontent.sync();
 /* ajax  start */
      $.ajax({
  url:"/admin/article/updateArticle",
  type:"post",
  dataType:"json",
  data:$("#article").serialize(),
   success : function(data){
				if(data.status == 200){
					layer.alert("修改成功", {
						skin: "layui-layer-molv",
						closeBtn: 0
					}, function(){
						window.location.href=window.location.href;   
					});
				}else{
					layer.alert("修改失败", {
						skin: "layui-layer-molv",
						closeBtn: 0
					}, function(){
						parent.layer.close(index);
					});
				}
			}
  
  
  
  });
  
  /* ajax end */
         
        });
    
         
             }
      );
      
    
   
        


     layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload;
        //指定允许上传的文件类型
        upload.render({
            elem: '#test3'
            , url: '/upload/pic'
            , accept: 'file' //普通文件
            , done: function (res) {
             alert(res.data.src);
               $("[name=img]").val(res.data.src);
            }
        });
    });

</script>

</body>
</html>